package gptTest;

import chatgpt.ChatGPT;
import chatgpt.Images;
import chatgpt.entity.chat.Message;
import chatgpt.entity.images.Generations;
import chatgpt.entity.images.ImagesRensponse;
import chatgpt.util.Proxys;
import lombok.extern.slf4j.Slf4j;
import org.junit.Before;

import java.net.Proxy;

@Slf4j
public class GenImgs {
//    String apiKeys = "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";
//    String apiHost = "https://api.openai.com/";
//    Proxy proxy = Proxys.http("127.0.0.1", 19180);
    String apiKeys = "sk-vM175qlqxg9jT5RsBc4e402d84904c59Bc00Dc8f4fCf1640";
    String apiHost = "https://api.xi-ai.cn/";
    private Images imgs;

    @Before
    public void before() {
        imgs = Images.builder()
                .apiKey(apiKeys)
                .timeout(900)
                .apiHost(apiHost)
//                .proxy(proxy)
                .build()
                .init();
    }

    @org.junit.Test
    public void genImg() {
        Generations generations = Generations.builder()
                .n(1)
                .size("500x500")
                .prompt("生成古风男子腰间斜跨一柄长剑，长发飘逸，依靠在树旁")
                .response_format("url")
                .build();
        ImagesRensponse img  = imgs.generations(generations);
//        Message res = img.getChoices().get(0).getMessage();
        String res = img.getCode();
        System.out.println(res+"-----");
        System.out.println(res);
        System.out.println(img.toString());

    }

}
